<%= form_for [current_event, @category], html: {class: 'form-horizontal'} do |f|%>

  <div class="form-group"><label class="col-sm-2 control-label">标签名称</label>
    <div class="col-sm-3"> <%=f.text_field :name, class: 'form-control'%> </div>
  </div>

  <div class="form-group"><label class="col-sm-2 control-label">标签颜色</label>
    <div class="col-sm-3">
      <input id="activity_category_color" value="<%= @category.category_color %>" type="text" name="activity_category[category_color]" class='form-control' style='background: <%= @category.category_color %>; cursor:pointer;'>
      </div>
  </div>

  <div class="form-group">
    <div class="col-sm-4 col-sm-offset-2">
      <%=link_to '取消', event_activity_categories_path, class: 'btn btn-white'%>
      <%= button_tag '保存', class: 'btn btn-primary'%>
    </div>
  </div>

<% end %>

<script type="text/javascript">
  $(function(){
    $('#activity_category_color').ColorPicker({  
      color: '#ff0000',
      onSubmit: function(hsb, hex, rgb, el, parent) {
        $(el).css('background', '#'+hex);
        $(el).val('#'+hex);  
        $(el).ColorPickerHide();  
      },  
      onBeforeShow: function () {
        $(this).ColorPickerSetColor(this.value);  
      }  
    }).bind('keyup', function(){
        $(this).ColorPickerSetColor(this.value);  
    });  
  });
</script>